package
{
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.ColorMatrixFilter;
	import flash.filters.ConvolutionFilter;
	import flash.geom.Matrix;
	import flash.net.URLRequest;
	
	public class TestFilter extends Sprite
	{
		private		var loader:Loader = null;
		
		public function TestFilter()
		{
			super();
			
			this.loader = new Loader();
			var urlReq:URLRequest = new URLRequest("./assets/test.png");
			
			this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
			this.loader.load(urlReq);
			
//			var sprite:Sprite = new Sprite();
//			sprite.graphics.beginFill(0xff0000);
//			sprite.graphics.drawRect(0, 0, 100, 50);
//			sprite.graphics.endFill();
//			sprite.filters = [new ConvolutionFilter(3,3,[0,0,0,0,3,0,0,0,0],3)];
//			this.addChild(sprite);
		}
		
		public	function	onLoadComplete(evt:Event):void{
			var img:Bitmap = this.loader.content as Bitmap;
			this.addChild(img);
			
			//img.filters = [new ConvolutionFilter(3,3,[1,1,1,1,3,1,1,1,1],11)];
			
//			img.filters = [new ConvolutionFilter(3,3,[-2,-1,0,-1,1,1,0,1,2])];//浮雕
			
			//img.filters =[new ColorMatrixFilter([-1,0,0,0,255,0,-1,0,0,255,0,0,-1,0,255,0,0,0,1,0])];
			
//			img.filters = [new ColorMatrixFilter([0.3086,0.6094,0.0820,0,0,0.3086,0.6094,0.0820,0,
//				0,0.3086,0.6094,0.0820,0,0,0,0,0,1,0])];
		
			//img.filters = [new ColorMatrixFilter([2,0,0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,1,0])]
			var matrix:Matrix = img.transform.matrix;
			matrix.a = 2;
			matrix.d = 2;
			img.transform.matrix = matrix;
		}
	}
}